# -*- coding: utf-8 -*-
#
# File: Install.py
#
# Copyright (c) 2007 by LM
# Generator: ArchGenXML Version 1.5.1 svn/devel
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

__author__ = """LM <leonardo.mirandas@gmail.com>"""
__docformat__ = 'plaintext'


from Products.CMFCore.utils import getToolByName
from Products.ExternalMethod.ExternalMethod import ExternalMethod

##code-section module-header #fill in your manual code here
##/code-section module-header

def installWorkflows(self, package, out):
    """Install the custom workflows for this product."""

    productname = 'GrupoVisao'
    workflowTool = getToolByName(self, 'portal_workflow')

    #CADASTRANDO O JORNAL WORKFLOW
    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'jornal_workflow',
                                        'createjornal_workflow')
    workflow = ourProductWorkflow(self, 'jornal_workflow')
    if 'jornal_workflow' in workflowTool.listWorkflows():
        print >> out, 'jornal_workflow already in workflows.'
    else:
        workflowTool._setObject('jornal_workflow', workflow)
    workflowTool.setChainForPortalTypes(['jornal'], workflow.getId())

    #CADASTRANDO O CURRICULO WORKFLOW
    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'curriculo_workflow',
                                        'createcurriculo_workflow')
    workflow = ourProductWorkflow(self, 'curriculo_workflow')
    if 'curriculo_workflow' in workflowTool.listWorkflows():
        print >> out, 'curriculo_workflow already in workflows.'
    else:
        workflowTool._setObject('curriculo_workflow', workflow)
    workflowTool.setChainForPortalTypes(['curriculo'], workflow.getId())
    
    
    #CADASTRANDO O AREA CIENTIFICA WORKFLOW
    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'area_cientifica_workflow',
                                        'createarea_cientifica_workflow')
    workflow = ourProductWorkflow(self, 'area_cientifica_workflow')
    if 'area_cientifica_workflow' in workflowTool.listWorkflows():
        print >> out, 'area_cientifica_workflow already in workflows.'
    else:
        workflowTool._setObject('area_cientifica_workflow', workflow)
        
    TIPOS_CIENTIFICOS = ['folder_programacao_cientifica','folder_resultado_provas','folder_publicacoes_cientifica','folder_banner_cientifico','folder_informe_cientifico','banner_cientifico','resultado_prova','informe_cientifico','publicacao_cientifica','programacao_cientifica',]
        
    workflowTool.setChainForPortalTypes(TIPOS_CIENTIFICOS, workflow.getId())    
    
    ##code-section after-workflow-install #fill in your manual code here
    ##/code-section after-workflow-install

    return workflowTool

def uninstallWorkflows(self, package, out):
    """Deinstall the workflows.

    This code doesn't really do anything, but you can place custom
    code here in the protected section.
    """

    ##code-section workflow-uninstall #fill in your manual code here
    ##/code-section workflow-uninstall

    pass
